home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / utilities / text / tec10.lha / Examples / ag2ansi.tec next >
Encoding:
Text File  |  1994-05-24  |  1.7 KB  |  90 lines

  1. % Convert AmigaGuide database to ASCII Text with ANSI Control Sequences
  2. % (c) 1994 Martin Mares, MJSoft System Software
  3.  
  4. begin:    '@' clr gatcmd        % Waiting for @node
  5.     '\n' begin
  6.     else midx
  7. midx:    '\n' begin
  8.     else midx
  9. gatcmd:    ' ' maycmd
  10.     '\n' begin
  11.     else add gatcmd
  12. maycmd:    switch "NODE" gotnode
  13.     else midx
  14.  
  15. gotnode:    '"' nodehd    % Print node name
  16.     '\n' begin
  17.     else gotnode
  18. nodehd:    '"' nodeig
  19.     '\n' begin
  20. nodeig:    '\n' copy nodei        % Ignore rest of line
  21.     else nodeig
  22.  
  23. nodei:    '@' clr gatnc        % Inside the node
  24.     '\n' copy nodei
  25.     else copy nodej
  26.  
  27. nodej:    '@' mayz
  28.     '\\' backs
  29.     '\n' copy nodei
  30.  
  31. gatnc2:    '\n' gatnev        % Command found
  32.     ' ' gatnes
  33.     else add
  34. gatnes:    '\n' gatnev
  35.     else
  36. gatnev:    switch "ENDNODE" begin
  37.     else nodei
  38. gatnc:    use gatnc2 '{' clr ctrl
  39.  
  40. mayz:    '{' clr ctrl
  41.     else put '@' copy nodej
  42.  
  43. backs:    '\\' '@' copy nodej    % Backslash found
  44.     '\n' put '\\' copy nodei
  45.     else put '\\' copy nodej
  46.  
  47. ctrl2:    '}' back cend        % Control characters
  48.     ' ' spac
  49.     else add
  50. ctrl:    use ctrl2 '"' ref
  51. spac:    ' '
  52.     else back cend
  53. cend:    switch
  54.         "b" bold ; "ub" unbold
  55.         "i" italic ; "ui" unital
  56.         "u" underl ; "uu" unund
  57.         "bg" backg ; "fg" foreg
  58.     else cign
  59. cign:    '}' nodej        % Ignore rest of ctrl sequence
  60.     else cign
  61.  
  62. bold:    put "\e[1m" cign    % ANSI sequences
  63. unbold:    put "\e[22m" cign
  64. italic:    put "\e[3m" cign
  65. unital:    put "\e[23m" cign
  66. underl:    put "\e[4m" cign
  67. unund:    put "\e[24m" cign
  68. backg:    put "\e[4" clr ccolor
  69. foreg:    put "\e[3" clr ccolor
  70.  
  71. ccolor:    ' ' ccole        % Color switches
  72.     '}' back ccole
  73.     else add
  74. ccole:    switch
  75.         "text" cc1
  76.         "shine" cc2
  77.         "shadow" cc1
  78.         "fill" cc3
  79.         "filltext" cc1
  80.         "back" cc0
  81.         "highlight" cc2
  82.     else cign
  83. cc0:    put "0m" cign
  84. cc1:    put "1m" cign
  85. cc2:    put "2m" cign
  86. cc3:    put "3m" cign
  87.  
  88. ref:    put "\e[7m" refloop    % Link - displayed in inverse video
  89. refloop: '"' put "\e[27m" cign
  90.